package com.foreveross.taskservice.taskcache;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
 * 查询索引
 * @author Administrator
 *
 */
public final class QueryIndex implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1381331222362817889L;
	private final Map<String,Object> indexMap=new HashMap<String, Object>();
	
	public Map<String,Object> getIndexMap(){
		return new HashMap<String, Object>(this.indexMap);
	}
	/**
	 * 添加double类型的索引
	 * @param queryIndex
	 * @param value
	 * @return
	 */
	public void put(String queryIndex,Double value){
		putObject(queryIndex, value);
	}
	/**
	 * 添加String类型的索引
	 * @param queryIndex
	 * @param value
	 * @return
	 */
	public void put(String queryIndex,String value){
		putObject(queryIndex, value);
	}
	
	public boolean remove(String queryIndex){
		if(this.indexMap.containsKey(queryIndex)){
			this.indexMap.remove(queryIndex);
			return true;
		}
		return false;
	}
	
	public void clear(){
		this.indexMap.clear();
	}
	
	private void putObject(String queryIndex,Object value){
		if(value==null){return;}
		this.indexMap.put(queryIndex, value);
	}
}
